<%@tag description="authorization form" pageEncoding="UTF-8"%>
<%@tag import="busterminalweb.authorization.User"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib tagdir="/WEB-INF/tags/busterminal/" prefix="bt"%>
<%@taglib uri="/WEB-INF/tags/tlds/Functions.tld" prefix="f"%>

<c:set var="user" scope="session" value="${user}" />

<c:if test="${!empty user and f:isActionAllowed('user.login', user.getRole()) and user.getRole() == 'PASSENGER'}">
    <form method="POST" action="MainServlet?action=user.login">
        <fieldset>
            <legend>Hello User!</legend>
            <div class="control-group">
                <label class="control-label" for="userLogin">Login:</label>
                <div class="controls">
                    <input class="myinput" type="text" id="login" name="login" value="">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="userPassword">Password:</label>
                <div class="controls">
                    <input class="myinput" type="password" id="password" name="password" value="">
                </div>
            </div>
        </fieldset>
        <input type="submit" class="btn btn-primary" name="saveButton" value="Login">
    </form>
</c:if>
<c:if test="${!empty user and f:isActionAllowed('user.logout', user.getRole())}">
    <form method="POST" action="MainServlet?action=user.logout">
        <fieldset>
            <div class="control-group">
                <label class="control-label" for="userName">Hello, ${user.getName()}</label>
            </div>
        </fieldset>
        <input type="submit" class="btn btn-primary" name="loginButton" value="Logout">
    </form>
</c:if>